﻿<avalondock:DockableContent x:Class="BOL.Apps.GeneNetworkBrowser.Controls.ProjectPane"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:converters="clr-namespace:BOL.Apps.GeneNetworkBrowser.Converters"
                    xmlns:local="clr-namespace:BOL.Apps.GeneNetworkBrowser.Controls"
                    xmlns:vm="clr-namespace:BOL.Apps.GeneNetworkBrowser.ViewModels"
                    FocusManager.FocusedElement="{Binding ElementName=_tbSearch}"
                    xmlns:avalondock="clr-namespace:AvalonDock;assembly=AvalonDock"
                    Title="Project"
                    ToolTip=""
                    Icon="/Images/ProjectPane.png"
                    >
    <avalondock:DockableContent.Resources>
        <converters:RefreshValueConverter x:Key="RefreshValueConverter" />
        <RoutedUICommand x:Key="EditingModeCommand" />
    </avalondock:DockableContent.Resources>
    <avalondock:DockableContent.CommandBindings>
        <CommandBinding Command="{StaticResource EditingModeCommand}" />
    </avalondock:DockableContent.CommandBindings>
    <!--<StackPanel>-->
        <TreeView x:Name="_tvProjectView" BorderThickness="0" DataContext="{Binding Project}">
            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                    <Setter Property="FontWeight" Value="Normal" />
                    <Setter Property="BorderThickness" Value="1"/>
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="FontWeight" Value="Bold" />
                            <Setter Property="BorderBrush" Value="#ADC6E5"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True"/>
                                <Condition Property="IsSelectionActive" Value="False"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="LightGray"/>
                        </MultiTrigger>
                    </Style.Triggers>
                    <!--<Style.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="2"/>
                    </Style>
                </Style.Resources>-->
                </Style>
            </TreeView.ItemContainerStyle>
            <TreeView.Resources>
                <!--<LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0,1" StartPoint="0,0">
                <GradientStop Color="#FFD9F4FF" Offset="0"/>
                <GradientStop Color="#FF9BDDFB" Offset="1"/>
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="{x:Static SystemColors.ControlBrushKey}" EndPoint="0,1" StartPoint="0,0">
                <GradientStop Color="#FFEEEDED" Offset="0"/>
                <GradientStop Color="#FFDDDDDD" Offset="1"/>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
            <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Black" />-->

                <HierarchicalDataTemplate DataType="{x:Type vm:ProjectTreeViewItemViewModel}" ItemsSource="{Binding Children}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Margin="0,0,3,0" Source="/Images/ProjectView.png" />
                        <TextBlock Name="_tbName" Text="{Binding Name}">
                        <TextBlock.Style>
                            <Style>
                                <Setter Property="local:MouseDoubleClick.Command" Value="{StaticResource EditingModeCommand}" />
                                <Setter Property="local:MouseDoubleClick.CommandParameter" Value="{Binding}" /> 
                            </Style>
                        </TextBlock.Style>
                        </TextBlock>
                        <TextBox Name="_tbEditName" Visibility="Collapsed" MinWidth="100" Text="{Binding Name, UpdateSourceTrigger=LostFocus, Converter={StaticResource RefreshValueConverter}}">
                            <TextBox.InputBindings>
                                <KeyBinding Key="Enter" Command="{StaticResource EditingModeCommand}" />
                            </TextBox.InputBindings>
                        </TextBox>
                    </StackPanel>
                    <HierarchicalDataTemplate.Triggers>
                        <DataTrigger Binding="{Binding IsEditing}" Value="True">
                            <Setter TargetName="_tbName" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="_tbEditName" Property="Visibility" Value="Visible" />
                        </DataTrigger>
                    </HierarchicalDataTemplate.Triggers>
                </HierarchicalDataTemplate>
                <HierarchicalDataTemplate DataType="{x:Type vm:NetworksTreeViewItemViewModel}" ItemsSource="{Binding Children}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Margin="0,0,3,0" Source="/Images/Network.png" />
                        <TextBlock Text="{Binding Name}" />
                        <TextBlock Foreground="Blue" Text="{Binding Networks.Count, StringFormat=' ({0})'}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
                <HierarchicalDataTemplate DataType="{x:Type vm:NetworkTreeViewItemViewModel}" ItemsSource="{Binding Children}">
                    <StackPanel Orientation="Horizontal">
                        <StackPanel.ContextMenu>
                            <ContextMenu ItemsSource="{Binding Path=ContextMenuItems}">
                                <ContextMenu.ItemTemplate>
                                    <DataTemplate>
                                        <MenuItem Header="{Binding Name}" Command="{Binding Command}"/>
                                    </DataTemplate>
                                </ContextMenu.ItemTemplate>
                            </ContextMenu>
                        </StackPanel.ContextMenu>
                        <Image Width="16" Height="16" Margin="0,0,3,0" Source="/Images/Network.png" />
                        <TextBlock Text="{Binding Name}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
                <HierarchicalDataTemplate DataType="{x:Type vm:GenesTreeViewItemViewModel}" ItemsSource="{Binding Children}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Margin="0,0,3,0" Source="/Images/Genes.png" />
                        <TextBlock Text="{Binding Name}" />
                        <TextBlock Foreground="Blue" Text="{Binding Genes.Count, StringFormat=' ({0})'}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
                <DataTemplate DataType="{x:Type vm:GeneTreeViewItemViewModel}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Margin="0,0,3,0" Source="/Images/Gene.png" />
                        <TextBlock Text="{Binding Name}" />
                    </StackPanel>
                </DataTemplate>
                <HierarchicalDataTemplate DataType="{x:Type vm:RelationsTreeViewItemViewModel}" ItemsSource="{Binding Children}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Margin="0,0,3,0" Source="/Images/Relations.png" />
                        <TextBlock Text="{Binding Name}" />
                        <TextBlock Foreground="Blue" Text="{Binding Relations.Count, StringFormat=' ({0})'}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
                <DataTemplate DataType="{x:Type vm:RelationTreeViewItemViewModel}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Margin="0,0,3,0" Source="/Images/Relation.png" />
                        <TextBlock Text="{Binding Name}" />
                    </StackPanel>
                </DataTemplate>
                <HierarchicalDataTemplate DataType="{x:Type vm:AnalysesTreeViewItemViewModel}" ItemsSource="{Binding Children}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Margin="0,0,3,0" Source="/Images/Network.png" />
                        <TextBlock Text="{Binding Name}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
                <DataTemplate DataType="{x:Type vm:AnalysisTreeViewItemViewModel}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Margin="0,0,3,0" Source="/Images/Relation.png" />
                        <TextBlock Text="{Binding Name}" />
                    </StackPanel>
                </DataTemplate>
            </TreeView.Resources>
        </TreeView>
        <!--<StackPanel HorizontalAlignment="Center" Margin="2" Orientation="Horizontal">
            <TextBlock Text="Search" VerticalAlignment="Center" />
            <TextBox x:Name="_tbSearch" KeyDown="SearchTextBox_KeyDown" Margin="3,0" 
                     Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" Width="Auto" />
            <Button Command="{Binding SearchCommand}" Content="_Find" Padding="4,0" />
        </StackPanel>
    </StackPanel>-->
</avalondock:DockableContent>